<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
   /*  var arr =[3,2,5,1,9];
    var arr1 =arr.sort();
    console.log(arr1);   //sort只能对1到9之间的数做排序  从小到大 */
    var arr =[3,2,5,1,9];
    var arr1 = arr.sort(function(a,b){     //arr.sort()传入函数，数组元素排序
        return a-b;                       //arr.reverse() 对数组进行反序处理
    });
    console.log(arr1);
    </script>
</html>